import { observable, action, makeObservable } from "mobx";
import { PageDateSelect } from '@/types/pages/enum'
import { getIncomeLineChart,
    getProfitData,
    getPieIProfitTypeChart,
    getIncomeData,
    getPieIncomeTypeChart,
    getProfitLineChart,
    getTotalIncomeData,
    getTotalProfitData
} from "@/api/financeCosts";
import { IFinanceConsts } from "@/types/pages/finance/interface";
import { IStore } from "@/types/pages/base";

/**
 * class FinanceConsts
 * 财务成本
 */
class FinanceConsts  implements IStore<IFinanceConsts> {
    @observable screenData :IFinanceConsts= {
        profit: {}, income: {}, incomeTypePie: {},
        profitData: {}, profitTypePie: {}, incomeLine: {}, profitLine: {},
        incomeData: {}
    }

    constructor() {
      makeObservable(this)
    }
   /**
     *
     * @param type 日期选择函数
     * @param date 传入日期
     */
     @action async getScreenData(type: PageDateSelect,date?:Date) {
        // 获取左上部分
        this.screenData.incomeLine= await getIncomeLineChart(type,date);
        this.screenData.profitData= await getProfitData(type,date);
        this.screenData.profitTypePie= await getPieIProfitTypeChart(type,date);
        this.screenData.incomeData= await getIncomeData(type,date);
        this.screenData.incomeTypePie= await getPieIncomeTypeChart(type,date);
        this.screenData.profitLine= await getProfitLineChart(type,date);
        this.screenData.income=await  getTotalIncomeData(type,date);
        this.screenData.profit=await  getTotalProfitData(type,date);
        return  this.screenData;
    }


}
export default FinanceConsts;
